//
//  SISSRentOutView.m
//  SISSAPP
//
//  Created by 袁应荣 on 2017/12/15.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSRentOutView.h"
#import "SISSTitleView.h"

@interface SISSRentOutView ()<SDCycleScrollViewDelegate,MWPhotoBrowserDelegate>

/* 图片轮播 */
@property (weak, nonatomic) SDCycleScrollView *cycleScrollView;
/* 图片分页 */
@property (weak, nonatomic) UILabel *pageLabel;
/* 图片链接数组 */
@property (strong, nonatomic) NSArray *imagesURLStrings;

@property (weak, nonatomic)  UILabel *mothlyRentLabel;
@property (weak, nonatomic)  UILabel *wayOfPaymentLabel;
@property (weak, nonatomic)  UILabel *lessorLabel;
@property (weak, nonatomic)  UILabel *regionAndDetailLabel;
@property (weak, nonatomic)  UILabel *releaseTimeLabel;
@property (weak, nonatomic)  UIView *houseFeatureView;
@property (strong, nonatomic) NSArray<UILabel *> *houseFeatureLabels;
@property (weak, nonatomic)  UIView *horizontalLineOne;
@property (weak, nonatomic)  UIView *horizontalLineTwo;
@property (weak, nonatomic)  UIView *verticalLineOne;
@property (weak, nonatomic)  UIView *verticalLineTwo;
@property (weak, nonatomic)  UIView *verticalLineThree;
@property (weak, nonatomic)  UILabel *areaLabel;
@property (weak, nonatomic)  UILabel *directionLabel;
@property (weak, nonatomic)  UILabel *decorationLabel;
@property (weak, nonatomic)  UILabel *floorLabel;

@property (weak, nonatomic)  UILabel *areaTitleLabel;
@property (weak, nonatomic)  UILabel *directionTitleLabel;
@property (weak, nonatomic)  UILabel *decorationTitleLabel;
@property (weak, nonatomic)  UILabel *floorTitleLabel;

@property (weak, nonatomic)  SISSTitleView *titleView;
@property (weak, nonatomic)  UIView *houseAllocationView;
@property (strong, nonatomic) NSArray<UILabel *> *houseAllocationLabels;
@property (weak, nonatomic)  UILabel *additionalNoteLabel;

@end
@implementation SISSRentOutView

- (void)setRentOutModel:(SISSRentOutModel *)rentOutModel {
    _rentOutModel = rentOutModel;
    
    self.imagesURLStrings = rentOutModel.image.count > 0 ? rentOutModel.image : rentOutModel.imagesArray;
    self.cycleScrollView.imageURLStringsGroup = self.imagesURLStrings;
    if (rentOutModel.image.count <= 0) self.cycleScrollView.localizationImageNamesGroup = self.imagesURLStrings;

    NSInteger index = self.imagesURLStrings.count > 0 ? 1 : 0;
    self.pageLabel.text = [NSString stringWithFormat:@"%zd/%zd",index,self.imagesURLStrings.count];
    
    [self.cycleScrollView mas_updateConstraints:^(MASConstraintMaker *make) {
        if (self.imagesURLStrings.count == 0) {
           make.height.mas_equalTo(0.01);
            self.pageLabel.hidden = YES;
        } else {
            make.height.mas_equalTo(160);
            self.pageLabel.hidden = NO;
        }
    }];
    
    self.mothlyRentLabel.text = [NSString stringWithFormat:@"%@元",rentOutModel.monthlyRent];
    self.wayOfPaymentLabel.text = [rentOutModel.foregift integerValue] ? [NSString stringWithFormat:@"押%@付%@",rentOutModel.foregift,rentOutModel.pay] : @"押-付-";
    NSString *lessor = @"";
    if (rentOutModel.lessor == 1) {
        lessor = @" 个人房源 ";
    } else if (rentOutModel.lessor == 2) {
        lessor = @" 机构房源 ";
    } else if (rentOutModel.lessor == 3) {
        lessor = @" 品牌公寓 ";
    }
    self.lessorLabel.text = lessor;
    self.regionAndDetailLabel.text = [NSString stringWithFormat:@"%@ | %@ | %@-%@",rentOutModel.houseType,rentOutModel.neighbourhood,rentOutModel.region,rentOutModel.regionDetail];
    self.releaseTimeLabel.text = [NSDate yyr_stringToString:rentOutModel.insertTime];
    
    WeakSelf
    CGFloat margin = 8.0;
    if ([UILabel getWidthWithTitle:self.regionAndDetailLabel.text font:[UIFont systemFontOfSize:16]] + [UILabel getWidthWithTitle:self.releaseTimeLabel.text font:[UIFont systemFontOfSize:16]] + 40 > SCREEN_WIDTH) {
        
        [self.releaseTimeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.regionAndDetailLabel);
            make.top.equalTo(weakSelf.regionAndDetailLabel.mas_bottom).offset(2 * margin);
        }];
        [self.houseFeatureView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.mothlyRentLabel);
            make.top.equalTo(weakSelf.releaseTimeLabel.mas_bottom).offset(2 * margin);
            make.right.equalTo(weakSelf).offset(-2 * margin);
            make.height.mas_equalTo(self.houseFeatureLabels.lastObject.frame.origin.y + 30);
        }];
    } else {
        [self.releaseTimeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf).offset(-2 * margin);
            make.centerY.equalTo(weakSelf.regionAndDetailLabel);
        }];
        
        [self.houseFeatureView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.mothlyRentLabel);
            make.top.equalTo(weakSelf.regionAndDetailLabel.mas_bottom).offset(2 * margin);
            make.right.equalTo(weakSelf).offset(-2 * margin);
            make.height.mas_equalTo(self.houseFeatureLabels.lastObject.frame.origin.y + 30);
        }];
    }
    
    self.areaLabel.text = [NSString stringWithFormat:@"%@㎡",rentOutModel.area.length > 0 ? rentOutModel.area : @"--"];
    self.directionLabel.text = rentOutModel.direction.length > 0 ? rentOutModel.direction : @"--";
    self.decorationLabel.text = rentOutModel.decoration.length > 0 ? rentOutModel.decoration : @"--";
    self.floorLabel.text = [NSString stringWithFormat:@"%@层",rentOutModel.floor.length > 0 && [rentOutModel.floor integerValue] > 0 ? rentOutModel.floor : @"--"];
    
    self.additionalNoteLabel.text = rentOutModel.otherdesc;
    
    NSArray *houseFeatureArr = rentOutModel.houseFeature.length == 0 ? @[] : [rentOutModel.houseFeature componentsSeparatedByString:@"#"];
    for (NSInteger i = 0; i < houseFeatureArr.count ; i++) {
        UILabel *label = self.houseFeatureLabels[i];
        label.hidden = NO;
        label.text = houseFeatureArr[i];
        label.text = [NSString stringWithFormat:@"%@",houseFeatureArr[i]];
        UIColor *color = [SISSPublicMethods matchTextColorWithHouseFeatureStr:houseFeatureArr[i]];
        label.layer.borderColor = color.CGColor;
        label.textColor = color;
    }
    [self.houseFeatureView mas_updateConstraints:^(MASConstraintMaker *make) {
        if (houseFeatureArr.count == 0) {
            make.height.mas_equalTo(1);
        } else {
            make.height.mas_equalTo(self.houseFeatureLabels[houseFeatureArr.count - 1].frame.origin.y + 30);
        }
    }];
    
    NSArray *houseConfigureArr = rentOutModel.houseConfigure.length == 0 ? @[] : [rentOutModel.houseConfigure componentsSeparatedByString:@"#"];
    CGFloat labelX = 0;
    CGFloat labelY = 0;
    CGFloat labelWidth = 80;
    for (NSInteger i = 0; i < houseConfigureArr.count ; i++) {
        UILabel *label = self.houseAllocationLabels[i];
        label.hidden = NO;
        label.text = houseConfigureArr[i];
        label.text = [NSString stringWithFormat:@"%@",houseConfigureArr[i]];
//        UIColor *color = [self matchHouseConfigureTextColorWithStr:houseConfigureArr[i]];
//        label.layer.borderColor = color.CGColor;
        label.layer.backgroundColor = COLOR(0x84DFD8).CGColor;
        label.textColor = [UIColor whiteColor];
        if (labelX + labelWidth + 20 > SCREEN_WIDTH) {
            labelX = 0;
            labelY += 36;
        }
        labelWidth = [UILabel getWidthWithTitle:houseConfigureArr[i] font:[UIFont systemFontOfSize:15]] + 16;
        CGRect frame = CGRectMake(labelX, labelY, labelWidth, 28);
        label.frame = frame;
        
        labelX = CGRectGetMaxX(label.frame) + 8;
        
    }
   
    [self.houseAllocationView mas_updateConstraints:^(MASConstraintMaker *make) {
        if (houseConfigureArr.count == 0) {
            make.height.mas_equalTo(1);
        } else {
            make.height.mas_equalTo(self.houseAllocationLabels[houseConfigureArr.count - 1].frame.origin.y + 30);
        }
    }];
}


#pragma mark -- SDCycleScrollViewDelegate 点击图片看大图
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    
    MWPhotoBrowser *photoBrowser = [[MWPhotoBrowser alloc] initWithDelegate:self];
    [photoBrowser setCurrentPhotoIndex:index];
    //    [photoBrowser showNextPhotoAnimated:YES];
    //    [photoBrowser showPreviousPhotoAnimated:YES];
    SISSNavigationController *navigationController = [[SISSNavigationController alloc] initWithRootViewController:photoBrowser];
    
    UIResponder *responder = self;
    UIViewController *viewController;
    while ((responder = [responder nextResponder])) {
        if ([responder isKindOfClass: [UIViewController class]]) {
            viewController = (UIViewController *)responder;
            break;
        }
    }
    navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
    [viewController presentViewController:navigationController animated:YES completion:nil];
}

- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return self.imagesURLStrings.count;
}

- (id<MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    
    //创建图片模型
    MWPhoto *photo = [MWPhoto photoWithURL:[NSURL URLWithString:self.imagesURLStrings[index]]];
    return photo;
}

#pragma mark - UI
- (void)initUI {
    [super initUI];
    
    self.backgroundColor = [UIColor whiteColor];
    
    // 网络加载 --- 创建带标题的图片轮播器
    SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage imageNamed:@"图片加载占位符"]];
    cycleScrollView.autoScroll = NO;
    cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
    cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
    cycleScrollView.itemDidScrollOperationBlock = ^(NSInteger currentIndex) {
        
        self.pageLabel.text = [NSString stringWithFormat:@" %zd/%zd ",currentIndex + 1,self.imagesURLStrings.count];
    };
    [self addSubview:cycleScrollView];
    self.cycleScrollView = cycleScrollView;
    
    UILabel *pageLabel = [[UILabel alloc] init];
    pageLabel.backgroundColor = [UIColor colorWithWhite:0.8 alpha:0.5];
    pageLabel.textColor = [UIColor whiteColor];
    pageLabel.text = [NSString stringWithFormat:@" %d/%zd ",1,self.imagesURLStrings.count];
    pageLabel.textAlignment = NSTextAlignmentCenter;
    pageLabel.layer.cornerRadius = 10;
    pageLabel.layer.masksToBounds = YES;
    [cycleScrollView addSubview:pageLabel];
    self.pageLabel = pageLabel;
    
    UILabel *mothlyRentLabel = [UILabel yyr_labelWithText:@"月租金" fontSize:20 textColor:[UIColor redColor]];
    mothlyRentLabel.font = [UIFont boldSystemFontOfSize:20];
    [self addSubview:mothlyRentLabel];
    self.mothlyRentLabel = mothlyRentLabel;
    
    UILabel *wayOfPaymentLabel = [UILabel yyr_labelWithText:@"  押付方式 " fontSize:16 textColor:MAIN_TEXT_COLOR];
    [self addSubview:wayOfPaymentLabel];
    self.wayOfPaymentLabel = wayOfPaymentLabel;
    
    UILabel *lessorLabel = [UILabel yyr_labelWithText:@" 出租方 " fontSize:16 textColor:SECONDARY_TEXT_COLOR];
    lessorLabel.layer.borderWidth = 1;
    lessorLabel.layer.cornerRadius = 2;
    lessorLabel.layer.borderColor = SECONDARY_TEXT_COLOR.CGColor;
//    lessorLabel.layer.masksToBounds = YES;
    [self addSubview:lessorLabel];
    self.lessorLabel = lessorLabel;
    
    UILabel *regionAndDetailLabel = [UILabel yyr_labelWithText:@"户型 | 小区 | 区域" fontSize:16 textColor:MAIN_TEXT_COLOR];
    [self addSubview:regionAndDetailLabel];
    self.regionAndDetailLabel = regionAndDetailLabel;
    
    UILabel *releaseTimeLabel = [UILabel yyr_labelWithText:@"发布时间" fontSize:16 textColor:MAIN_TEXT_COLOR];
    [self addSubview:releaseTimeLabel];
    self.releaseTimeLabel = releaseTimeLabel;
    
    UIView *houseFeatureView = [[UIView alloc] init];
    [self addSubview:houseFeatureView];
    self.houseFeatureView = houseFeatureView;
    
    NSMutableArray *tagLabelsArr = [NSMutableArray arrayWithCapacity:5];
    CGFloat labelX = 0;
    CGFloat labelY = 0;
    CGFloat labelWidth = 72;
    for (NSInteger i = 0; i < 6; i++) {
        if (labelX + labelWidth + 20 > SCREEN_WIDTH) {
            labelX = 0;
            labelY += 36;
        }
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(labelX, labelY, labelWidth, 28)];
        label.text = @"房源特色";
        label.font = [UIFont systemFontOfSize:15];
        label.textAlignment = NSTextAlignmentCenter;
        label.layer.borderWidth = 1;
        label.layer.cornerRadius = 4;
        label.layer.borderColor = SECONDARY_TEXT_COLOR.CGColor;
        label.layer.masksToBounds = YES;
        [houseFeatureView addSubview:label];
        
        labelX = CGRectGetMaxX(label.frame) + 10;
        label.hidden = YES;
        [tagLabelsArr addObject:label];
    }
    self.houseFeatureLabels = tagLabelsArr.copy;
    
    UIView *horizontalLineOne = [[UIView alloc] init];
    horizontalLineOne.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:horizontalLineOne];
    self.horizontalLineOne = horizontalLineOne;
    
    UIView *horizontalLineTwo = [[UIView alloc] init];
    horizontalLineTwo.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:horizontalLineTwo];
    self.horizontalLineTwo = horizontalLineTwo;
    
    UIView *verticalLineOne = [[UIView alloc] init];
    verticalLineOne.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:verticalLineOne];
    self.verticalLineOne = verticalLineOne;
    
    UIView *verticalLineTwo = [[UIView alloc] init];
    verticalLineTwo.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:verticalLineTwo];
    self.verticalLineTwo = verticalLineTwo;
    
    UIView *verticalLineThree = [[UIView alloc] init];
    verticalLineThree.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:verticalLineThree];
    self.verticalLineThree = verticalLineThree;
    
    UILabel *areaTitleLabel = [UILabel yyr_labelWithText:@"面积" fontSize:16 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:areaTitleLabel];
    self.areaTitleLabel = areaTitleLabel;
    
    UILabel *areaLabel = [UILabel yyr_labelWithText:@"--" fontSize:17 textColor:COLOR(0xFF6286)];
    [self addSubview:areaLabel];
    self.areaLabel = areaLabel;
    
    UILabel *directionTitleLabel = [UILabel yyr_labelWithText:@"朝向" fontSize:16 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:directionTitleLabel];
    self.directionTitleLabel = directionTitleLabel;
    
    UILabel *directionLabel = [UILabel yyr_labelWithText:@"--" fontSize:17 textColor:COLOR(0xFF6286)];
    [self addSubview:directionLabel];
    self.directionLabel = directionLabel;
    
    UILabel *decorationTitleLabel = [UILabel yyr_labelWithText:@"装修" fontSize:16 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:decorationTitleLabel];
    self.decorationTitleLabel = decorationTitleLabel;
    
    UILabel *decorationLabel = [UILabel yyr_labelWithText:@"--" fontSize:17 textColor:COLOR(0xFF6286)];
    [self addSubview:decorationLabel];
    self.decorationLabel = decorationLabel;
    
    UILabel *floorTitleLabel = [UILabel yyr_labelWithText:@"楼层" fontSize:16 textColor:SECONDARY_TEXT_COLOR];
    [self addSubview:floorTitleLabel];
    self.floorTitleLabel = floorTitleLabel;
    
    UILabel *floorLabel = [UILabel yyr_labelWithText:@"--" fontSize:16 textColor:COLOR(0xFF6286)];
    [self addSubview:floorLabel];
    self.floorLabel = floorLabel;
    
    SISSTitleView *titleView = [[SISSTitleView alloc] init];
    titleView.titleStr = @"房源详情";
    [self addSubview:titleView];
    self.titleView = titleView;
    
    UIView *houseAllocationView = [[UIView alloc] init];
    [self addSubview:houseAllocationView];
    self.houseAllocationView = houseAllocationView;
    
    NSMutableArray *allocationLabelsArr = [NSMutableArray arrayWithCapacity:5];
    labelX = 0;
    labelY = 0;
    labelWidth = 80;
    for (NSInteger i = 0; i < 11; i++) {
        if (labelX + labelWidth + 20 > SCREEN_WIDTH) {
            labelX = 0;
            labelY += 36;
        }
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(labelX, labelY, labelWidth, 28)];
        label.text = @"房源配置";
        label.font = [UIFont systemFontOfSize:15];
        label.textAlignment = NSTextAlignmentCenter;
//        label.layer.borderWidth = 1;
//        label.layer.borderColor = SECONDARY_TEXT_COLOR.CGColor;
        label.layer.cornerRadius = 4;
//        label.layer.masksToBounds = YES;
        [houseAllocationView addSubview:label];
        
        labelX = CGRectGetMaxX(label.frame) + 8;
        label.hidden = YES;
        [allocationLabelsArr addObject:label];
    }
    self.houseAllocationLabels = allocationLabelsArr.copy;
    
    UILabel *additionalNoteLabel = [UILabel yyr_labelWithText:@"补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明补充说明" fontSize:16 textColor:MAIN_TEXT_COLOR];
    [self addSubview:additionalNoteLabel];
    self.additionalNoteLabel = additionalNoteLabel;
}

#pragma mark - 约束
- (void)initConstraint {
    [super initConstraint];
    WeakSelf
    CGFloat margin = 8.0;
    
    [self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf);
        make.top.equalTo(weakSelf).offset(margin);
        make.height.mas_equalTo(20 * margin);
    }];
    
    [self.pageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.cycleScrollView).offset(-2 * margin);
        make.width.mas_equalTo(5 * margin);
        make.bottom.equalTo(weakSelf.cycleScrollView).offset(-margin);
    }];
    
    [self.mothlyRentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.cycleScrollView.mas_bottom).offset(margin);
        make.left.equalTo(weakSelf).offset(3 * margin);
    }];
    
    [self.wayOfPaymentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mothlyRentLabel.mas_right).offset(margin);
        make.bottom.equalTo(weakSelf.mothlyRentLabel);
    }];
    
    [self.lessorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf).offset(-2 * margin);
        make.centerY.equalTo(weakSelf.mothlyRentLabel);
        make.height.mas_equalTo(3 * margin);
    }];
    
    [self.regionAndDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mothlyRentLabel);
        make.top.equalTo(weakSelf.mothlyRentLabel.mas_bottom).offset(2 * margin);
    }];
    
    [self.releaseTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf).offset(-2 * margin);
        make.centerY.equalTo(weakSelf.regionAndDetailLabel);
    }];
    
    [self.houseFeatureView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mothlyRentLabel);
        make.top.equalTo(weakSelf.regionAndDetailLabel.mas_bottom).offset(2 * margin);
        make.right.equalTo(weakSelf).offset(-2 * margin);
        make.height.mas_equalTo(self.houseFeatureLabels.lastObject.frame.origin.y + 30);
    }];
    
    [self.horizontalLineOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mothlyRentLabel);
        make.top.equalTo(weakSelf.houseFeatureView.mas_bottom).offset(2 * margin);
        make.right.equalTo(weakSelf).offset(-3 * margin);
        make.height.mas_equalTo(1);
    }];
    
    [self.verticalLineOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.horizontalLineOne.mas_bottom).offset(2 * margin);
        make.centerX.equalTo(weakSelf).multipliedBy(0.5);
        make.height.mas_equalTo(60);
        make.width.mas_equalTo(1);
    }];
    
    [self.verticalLineTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.horizontalLineOne.mas_bottom).offset(2 * margin);
        make.centerX.equalTo(weakSelf);
        make.height.mas_equalTo(60);
        make.width.mas_equalTo(1);
    }];
    
    [self.verticalLineThree mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.horizontalLineOne.mas_bottom).offset(2 * margin);
        make.centerX.equalTo(weakSelf).multipliedBy(1.5);
        make.height.mas_equalTo(60);
        make.width.mas_equalTo(1);
    }];
    
    [self.horizontalLineTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.height.width.equalTo(weakSelf.horizontalLineOne);
        make.top.equalTo(weakSelf.verticalLineOne.mas_bottom).offset(2 * margin);
    }];
    
    [self.areaTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mothlyRentLabel);
        make.top.equalTo(weakSelf.horizontalLineOne.mas_bottom).offset(2.5 * margin);
    }];

    [self.areaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.areaTitleLabel);
        make.top.equalTo(weakSelf.areaTitleLabel.mas_bottom).offset(margin);
    }];
    
    [self.directionTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.areaTitleLabel);
        make.left.equalTo(weakSelf.verticalLineOne.mas_right).offset(2 * margin);
    }];

    [self.directionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.directionTitleLabel);
        make.centerY.equalTo(weakSelf.areaLabel);
    }];

    [self.decorationTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.areaTitleLabel);
        make.left.equalTo(weakSelf.verticalLineTwo.mas_right).offset(2 * margin);
    }];

    [self.decorationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.decorationTitleLabel);
        make.centerY.equalTo(weakSelf.areaLabel);
    }];

    [self.floorTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.decorationTitleLabel);
        make.left.equalTo(weakSelf.verticalLineThree.mas_right).offset(2 * margin);
    }];

    [self.floorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.floorTitleLabel);
        make.centerY.equalTo(weakSelf.areaLabel);
    }];

    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf);
        make.top.equalTo(weakSelf.horizontalLineTwo.mas_bottom);
        make.height.mas_equalTo(5 * margin);
    }];
    
    [self.houseAllocationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mothlyRentLabel);
        make.top.equalTo(weakSelf.titleView.mas_bottom).offset(2 * margin);
        make.right.equalTo(weakSelf).offset(-2 * margin);
        make.height.mas_equalTo(self.houseAllocationLabels.lastObject.frame.origin.y + 30);
    }];
    
    [self.additionalNoteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.houseAllocationView.mas_bottom).offset(3 * margin);
        make.left.equalTo(weakSelf.mothlyRentLabel);
        make.right.equalTo(weakSelf).offset(-2 * margin);
        make.bottom.lessThanOrEqualTo(weakSelf);
    }];
}


@end
